//对d单个信息进行编辑
function processSubject(subject) {
  var title = subject.title;//获取标题
  var directors = subject.directors;//获取作者集群
  var directorStr = "";//创建单个作者
  for (var index in directors) {   //遍历出单个作者
    directorStr = directorStr + directors[index].name + " / ";
  }
  if (directorStr != "") {  //判断作者有无取消后面的斜杠"/"
    directorStr = directorStr.substring(0, directorStr.length - 2);
  }
  var casts = subject.casts;
  var castStr = "";
  for (var index in casts) {
    castStr = castStr + casts[index].name + " / ";
  }
  if (castStr != "") {
    castStr = castStr.substring(0, castStr.length - 2);
  }
  var genres = subject.genres;
  var genreStr = "";
  for (var index in genres) {
    genreStr = genreStr + genres[index] + " / ";
  }
  if (genreStr != "") {
    genreStr = genreStr.substring(0, genreStr.length - 2);
  }
  var year = subject.year;
  var text = "名称：" + title + "\n导演：" + directorStr + "\n主演：" + castStr + "\n类型：" + genreStr + "\n上映年份：" + year + "（中国大陆）";
  subject.text = text;//将所获取的text属性值进行赋值
}
//对多个信息进行循环遍历
function processSubjects(subjects) { 
  for (var i = 0; i < subjects.length; i++) {
    var subject = subjects[i];
    this.processSubject(subject);
  }
}
//暴露出接口
module.exports = {
  processSubject: processSubject,
  processSubjects: processSubjects
}